var ProReport = function () {
  var template = /*html*/ `
    <div class="pro-report">
      <el-table border fit show-summary :data="proReports" :summary-method="proReportSummary" style="width: 100%">
        <el-table-column :resizable="false" prop="machining" label="加工对象"></el-table-column>
        <el-table-column :resizable="false" prop="color" label="加工颜色"></el-table-column>
        <el-table-column :resizable="false" prop="orderCount" label="订单数量"></el-table-column>
        <el-table-column :resizable="false" prop="qualified" label="合格数"></el-table-column>
        <el-table-column :resizable="false" prop="touchTime" label="最后报工时间"></el-table-column>
      </el-table>
    </div>
  `;

  return {
    props: {
      proReports: {
        type: Array,
        default: function () {
          return [];
        }
      }
    },
    data: function () {
      return {};
    },
    methods:{
      proReportSummary:function(param){
        var columns = param.columns;
        var data = param.data;
        var sums = ['合计'];
        for (var i = 1; i < columns.length; i++) {
          var column = columns[i];
          var property = column.property;
          if (['orderCount','qualified'].indexOf(property) === -1) {
            sums.push(null);
            continue;
          }
          var dataSum = _.sumBy(data, property);
          sums.push(dataSum);
        }

        return sums;
      }
    },
    template: template
  };
}();